package com.cdht.util;

import java.nio.charset.Charset;

import com.cdht.exception.DataException;

public class StringUtils {

    /**
     * 验证字符串是否为空
     * @param str
     * @return
     */
    public static boolean isEmpty(String str) {
        if (str == null || str.trim().isEmpty()) {
            return true;
        }
        return false;
    }
    
    /**
     * 验证字符串是否为非空
     * @param str
     * @return
     */
    public static boolean isNotEmpty(String str) {
        return !isEmpty(str);
    }

    /**
     * byte[] to String
     * @param data
     * @return
     */
    public static String  toString(byte[] data)  {
        try {
            String result = new String(data,Charset.forName("UTF-8"));
            return result;
        } catch (Exception e) {
            DataException.throwException(e.getMessage());
            
        }
        return null;
    }
    
}
